home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!news
- From: austern@isolde.mti.sgi.com (Matt Austern)
- Newsgroups: comp.object,comp.lang.c++,comp.lang.java
- Subject: Re: Java: What's the Big Deal? (GC)
- Date: 02 Apr 1996 19:41:13 GMT
- Organization: SGI
- Message-ID: <AUSTERN.96Apr2114113@isolde.mti.sgi.com>
- References: <4jk4ee$7ri@newsbf02.news.aol.com> <1996Apr1.155416.12816@schbbs.mot.com>
- <MARKT.96Apr1200203@atlas.harlqn.co.uk>
- Reply-To: austern@mti.sgi.com
- NNTP-Posting-Host: isolde.mti.sgi.com
- In-reply-to: markt@harlqn.co.uk's message of 01 Apr 96 20:02:03 GMT
-
- In article <MARKT.96Apr1200203@atlas.harlqn.co.uk> markt@harlqn.co.uk (Mark Tillotson) writes:
-
- > > With Java's array, memory will be smashed into millions of small
- > > pieces. Here is a brief comparison:
- >
- > <array of struct of 3 floats example omitted>
- >
- > On many machines one load instruction is cheaper than multiplying an
- > index by 3, so Java's approach is actually faster (other things being
- > equal)...
-
- Until you think about locality (which is a very big deal: with today's
- CPUs, high cache hit rates are critical), or the effect of memory
- fragmentation, or the time required for many tiny allocations, or the
- space overhead of having lots of tiny memory blocks each with its own
- control header.
-
- Note that this isn't an argument against GC: it's an argument against
- writing programs that do many separate tiny allocations. This is true
- irespective of whether you're using GC or manual deallocation. It's
- also old news: lisp programmers have known for decades that your
- programs will be faster if you avoid excessive consing.
-
- Since this is crossposted to comp.land.c++, I'll note that C++ allows
- a very simple optimization: if you need many small heap-allocated
- objects of some type, you can redefine operator new for that type.
- This is useful for things like linked list nodes, and in cases like
- that it can yield enormous performance improvements.
- --
- Matt Austern
- SGI: MTI Compilers Group
- austern@isolde.mti.sgi.com
-